<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<div class="header">
	<h2>
		绩效考核模板信息<span><font color="red">（* 为必填项）</font> </span>
	</h2>
</div>
<form:form commandName="model" cssClass="validate"
	id="performanceSettingForm"
	action="performance/performanceSetting/save">
	<form:hidden path="id" />
	<table class=" form-table">
		<tbody>
			<tr>
				<td class="td1">模板名称：</td>
				<td class="td2"><form:input path="name" cssStyle="width:80%" cssClass="required"/>
				</td>

				<td class="td1">岗位：</td>
				<td class="td2"><form:select path="positionId" cssClass="required"
						data-allow-empty="true" items="${listPosition}" itemLabel="name"
						itemValue="id" />
				</td>
			</tr>

		</tbody>
	</table>
</form:form>

<div class="box tabbedBox">
	<div class="header">
		<ul>
			<li><a class="current" href="#preItems">考核指标</a></li>
			<li><a href="#positionUser">考核成员</a></li>
		</ul>
		<h2>&nbsp;</h2>
	</div>
	<div style="padding:0" class="content tabbed">
		<div id="preItems">
			<isperp:grid
				url="performance/performanceItem/listDetail?sourceId=${model.id }"
				gridId="preItemDetailGrid" showPager="false" showSearchbar="false"
				cusDialogSize="big"
				cusDeleteUrl="performance/performanceItem/delete"
				cusEditUrl="performance/performanceItem/edit"
				cusFormatterActions="true">
				<jsp:attribute name="toolbar">
		<isperp:toolbar id="iconToolbar">
		   
			 <isperp:button text="添加考核指标" icon="icon-plus"
							onclick="addPreItem();"></isperp:button>
		</isperp:toolbar>
		</jsp:attribute>
				<jsp:body>
		<isperp:column name="id" title="id" hidden="true"></isperp:column>
	    <isperp:column name="name" title="指标名称"></isperp:column>
	    <isperp:column name="target" title="目标"></isperp:column>
	    <isperp:column name="referenc_point" title="衡量标准"></isperp:column>
	    <isperp:column name="weight" title="权重"></isperp:column>
	    <isperp:column name="compute_type" title="取值方式"></isperp:column>
	</jsp:body>
			</isperp:grid>
		</div>

		<div id="positionUser">

			<isperp:grid gridId="roleUserGrid" idFieldName="id"
				url="performance/performanceSetting/listRelateUser?sourceId=${model.id }"
				gridTitle="考核成员" cusFormatterActions="true" showSearchbar="false"
				cusDeleteUrl="performance/performanceSettingUsers/delete">
				<jsp:attribute name="toolbar">
				<isperp:toolbar id="projectMemberGridToolbar">
					<isperp:button id="projectMemberGridCreate" icon="icon-plus"
							text="新增成员" onclick="addRoleUser();"></isperp:button>
				</isperp:toolbar>
				</jsp:attribute>
				<jsp:body> 
				<isperp:column name="id" title="id" hidden="true"></isperp:column>
				<isperp:column name="name" title="用户帐号" width="100">
				</isperp:column>
				<isperp:column name="fullname" title="姓名" width="100">
				</isperp:column>
				<isperp:column name="position" title="职位" width="60">
				</isperp:column>
				<isperp:column name="mobile" title="移动电话" width="100">
				</isperp:column>
				</jsp:body>
			</isperp:grid>
		</div>
	</div>
</div>
<div style="display:none">
	<input id="selectSetPerson_input">
	<isperp:departmentUser displayValue="" ifIncludeNoRoleUser="false"
		afterSelected="afterSelect_selectSetPerson(row);" multiselect="true"
		displayValueStyle="width:249px;" displayValueCssClass="required"
		idFieldName="name" valueControlId="selectSetPerson_input"
		id="selectSetPerson" name="selectSetPerson"></isperp:departmentUser>
</div>
<isperp:buttonList>
	<button class="submit nui-mainbtn" onclick="isperp.submitForm();">保存</button>
</isperp:buttonList>
<script type="text/javascript">
	function addPreItem() {
		isperp.openDialog({
			id : "addPreItemDialog",
			windowSize : "normal",
			contentUrl : 'performance/performanceItem/edit?pcontrolid=preItemDetailGrid&sourceId=${model.id }',
			title : "新增"
		});
	}

	function addRoleUser() {
		$('#selectSetPerson').click();
		return false;
	}

	function afterSelect_selectSetPerson(row) {
		var names = row[0];
		var sourceId = '${model.id }';
		$.ajax({
			url : 'performance/performanceSetting/saveRelateUser',
			data : {
				sourceId : sourceId,
				userName : names
			},
			success : function(data) {
				roleUserGrid.search();
			}
		});

	}
</script>


